package com.yuexi.web;

import com.yuexi.syscode.SysCodeService;
import com.yuexi.syscode.cqe.DropListQuery;
import com.zenx.dto.SingleResponse;
import com.zenx.dto.TitleValueDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Set;

@Api(tags = "字典")
@RequestMapping("/code")
@RestController
public class SysCodeController {

    @Resource
    private SysCodeService sysCodeService;

//    @ApiOperation("获取字典信息")
//    @GetMapping("/query")
//    public SingleResponse<List<SysCodeDTO>> query(SysCodeQuery sysCodeQuery) {
//        return SingleResponse.success(sysCodeService.query(sysCodeQuery));
//    }
//
    @ApiOperation("字典下拉列表")
    @PostMapping("/droplist")
    public SingleResponse<List<TitleValueDTO>> dropList(@RequestBody DropListQuery dropListQuery) {
        return SingleResponse.success(sysCodeService.dropList(dropListQuery));
    }

    @ApiOperation("字典下拉列表--批量接口")
    @PostMapping("/code_list")
    public SingleResponse<Map<String, List<TitleValueDTO>>> dropListBatch(@RequestBody Set<String> codeIds) {
        return SingleResponse.success(sysCodeService.dropListBatch(codeIds));
    }

//    @ApiOperation("获取单个字典的一条记录")
//    @GetMapping("/get")
//    public SingleResponse<SysCodeDTO> get(SysCodeQuery sysCodeQuery) {
//        return SingleResponse.success(sysCodeService.getOne(sysCodeQuery));
//    }
//
//    @ApiOperation("获取字典")
//    @GetMapping("/list/{code}")
//    public SingleResponse<List<SysCodeDTO>> getList(@PathVariable("code") String code) {
//        return SingleResponse.success(sysCodeService.getList(code));
//    }
}
